<?php
class Application_Model_Syllabus{
	private static $_prixParPage;
	private static $_prixReliure;
	protected $_syllabusId;
	protected $_intitule;
	protected $_section;
	protected $_annee;
	protected $_nbPage;
	protected $_auteur;
	protected $_relie;
	protected $_livre;
	
	public function __set($name, $value){
		$method = 'set'.$name;
		if(($name == 'mapper') || !method_exists($this, $method)){
			throw new Exception('Invalid news property');
		}
		$this->$method($value);
	}
	public function __get($name){
		$method = 'get'.$name;
		if(($name=='mapper')||!method_exists($this, $method)){
			throw new Exception('Invalid news property');
		}
		return $this->$method();
	}
	public static function getPrixReliure(){
		if(null===self::$_prixReliure){
			$db = new Application_Model_DbTable_AppSettings();
			self::$_prixReliure = $db->getPrixReliure();
		}
		return self::$_prixReliure;
	}
	public static function getPrixParPage(){
		if(null === self::$_prixParPage){
			$db = new Application_Model_DbTable_AppSettings();
			self::$_prixParPage = $db->getPrixParPage();
		}
		return self::$_prixParPage;
	}
	public function setSyllabusId($id){
		$this->_syllabusId = (int) $id;
		return $this;
	}
	public function getSyllabusId(){
		return $this->_syllabusId;
	}
	public function setIntitule($inti){
		$this->_intitule = $inti;
		return $this;
	}
	public function getIntitule(){
		return $this->_intitule;
	}
	public function setSection($sect){
		$this->_section = $sect;
		return $this;
	}
	public function getSection(){
		return $this->_section;
	}
	public function setAnnee($an){
		$this->_annee = $an;
		return $this;
	}
	public function getAnnee(){
		return $this->_annee;
	}
	public function setNbPage($nb){
		$this->_nbPage = $nb;
		return $this;
	}
	public function getNbPage(){
		return $this->_nbPage;
	}
	public function setAuteur($aut){
		$this->_auteur = $aut;
		return $this;
	}
	public function getAuteur(){
		return $this->_auteur;
	}
	public function setRelie($rel){
		$this->_relie = $rel;
		return $this;
	}
	public function isRelie(){
		return $this->_relie;
	}
	public function setLivre($liv){
		$this->_livre = $liv;
		return $this;
	}
	public function isLivre(){
		return $this->_livre;
	}
	public function getPrix(){
		$prix = ceil($this->_nbPage*self::getPrixParPage()*10)/10;
		if($this->isRelie()){
			$prix+=self::getPrixReliure();
		}
		return $prix;
	}
}